package cn.leelei.work;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Controller
public class ControllerHandler {
    /**
     *
     * @return
     */
    @RequestMapping("/handler")
    public ModelAndView handler(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("name","Tom");
        modelAndView.setViewName("show");
        return modelAndView;
    }

    /**
     * 注解实现方式二
     * @param model
     * @return
     */
    @RequestMapping("/test")
    public String ModelAndView (Model model){

        model.addAttribute("name","TomNoke");
        return "show";
    }

    /**
     * map传值
     * @param
     * @return
     */
    @RequestMapping("/testmap")
    public String Modelmap (Map<String,String> stringMap){

        stringMap.put("name","TomNoke12345");
        return "show";
    }
}
